Skip to content

fix(detail): stabilize image-area height to stop the per-switch layout jump (CLS)#533

Merged
Zheaoli merged 1 commit into
mainfrom
fix/detail-image-cls
Jun 11, 2026
Merged

fix(detail): stabilize image-area height to stop the per-switch layout jump (CLS)#533
Zheaoli merged 1 commit into
mainfrom
fix/detail-image-cls

Conversation

@Zheaoli

@Zheaoli Zheaoli commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Symptom

After the histogram/zoom flicker fixes deployed, the detail view still visibly "flickered" / jumped on switch and load (Manjusaka, real device). Profiling pinned the residual cause: image-area CLS ~0.06 — the whole modal reflows on each switch.

Cause

The image area used sm:max-h-[90vh] (a max), so it sized to each photo's contained height. Switching between photos of different aspect ratios changed the row height every time → the modal jumped/reflowed.

Fix

Make the image area a fixed sm:h-[90vh] box on desktop; the carousel viewport and slides fill it (sm:h-full), and the image keeps object-contain centered. Different aspect ratios now letterbox within a constant-height box instead of resizing it → height no longer changes on switch → CLS ≈ 0, no jump.

  • Mobile unchanged (no sm: height → still sizes to content).
  • Accepted trade-off (agreed with the team): landscape photos get more top/bottom letterboxing within the fixed box — that's the cost of a stable height.
  • No change to the carousel logic, zoom viewer, or data.

Verification

tsc clean. Can't measure CLS headless on the modal path reliably; post-deploy: re-profile to confirm CLS → ~0 and Manjusaka confirms the switch/load jump is gone. Known secondary (deferred): the MotionImage 1s fade-in could be shortened if a "soft" fade still reads as flicker after this; and the ~313-mutation full re-render per switch (memoize slides/strip) remains a perf follow-up.

…ayout jump

The detail image area used `sm:max-h-[90vh]`, so it sized to each photo's
contained height — switching between photos of different aspect ratios changed
the row height every time, and the whole modal jumped/reflowed (measured CLS
~0.06; the remaining "flicker" on switch/load after the other fixes).

Make the image area a fixed `sm:h-[90vh]` box on desktop (carousel viewport and
slides fill it with `sm:h-full`); the image keeps `object-contain` and is centered,
so different aspect ratios now letterbox within a constant-height box instead of
resizing it. Height no longer changes on switch → CLS ≈ 0, no jump. Mobile is
unchanged (no `sm:` height → still sizes to content).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
picimpact Ready Ready Preview, Comment Jun 11, 2026 4:30pm

@Zheaoli Zheaoli merged commit b86e954 into main Jun 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant